export type WidgetType = 'input' | 'select'

/**
 * 基础组件配置
 */
export interface Widget {
  type: WidgetType
  field: string
  label: string
  disabled?: boolean
  message?: string
  placeholder?: string
  validate?: (value: string) => Promise<boolean>
}

/**
 * input widget
 */
export interface InputWidget extends Widget {
  type: 'input'
  maxLength?: number
}

/**
 * select options
 */
export interface SelectOptions {
  label: string
  value: any
  disabled?: boolean
}

/**
 * select widget
 */
export interface SelectWidget extends Widget {
  type: 'select'
  options:
    | Array<SelectOptions>
    | ((...args: any) => Array<SelectOptions> | Promise<Array<SelectOptions>>)
  _optionsData?: Array<SelectOptions>
}

export type Widgets = InputWidget | SelectWidget

export interface MultipleConditionSearchSchema {
  /**
   * 组件列表
   */
  widgets: Array<Widgets>

  /**
   * 输入框默认的placeholder
   */
  placeholder?: string

  /**
   * 组件最小宽度
   */
  minWidth?: number

  /**
   * 组件最大宽度
   */
  maxWidth?: number

  /**
   * 标签配置
   */
  tag?: {
    // 字段名称最大显示宽度
    maxLabelWidth?: number
    // 字段值最大显示宽度
    maxValueWidth?: number
  }
}

export const ProvideParamsSymbol = Symbol('ProvideParamsSymbol')
export const ProvideSchemaSymbol = Symbol('ProvideSchemaSymbol')
